package com.module.circle.ui.checkAcDetails

import android.view.View
import androidx.core.content.ContextCompat
import com.alibaba.android.arouter.facade.annotation.Route
import com.common.app.base.AppActivity
import com.common.app.core.RouterHub
import com.common.app.utls.HeadTitleUtils
import com.common.base.utils.StatusBarUtils
import com.module.circle.R
import com.module.circle.databinding.CircleActivityCheckAcDetailsBinding
import com.scwang.smart.refresh.footer.ClassicsFooter
import com.scwang.smart.refresh.header.ClassicsHeader
import com.scwang.smart.refresh.layout.api.RefreshLayout
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener

/**
 * 作者：sosou
 * <p>
 * 版本：1.0
 * <p>
 * 创建日期：28/6/2025
 * <p>
 * 描述：打卡活动页面
 * <p>
 * 修订历史：
 */
@Route(path = RouterHub.ROUTER_CIRCLE_CHECK_AC_DETAILS)
class CheckAcDetailsActivity : AppActivity<CircleActivityCheckAcDetailsBinding, CheckAcDetailsViewModel>(),View.OnClickListener {

    override fun getViewModel() = CheckAcDetailsViewModel::class.java

    override fun getViewContentBinding() = CircleActivityCheckAcDetailsBinding.inflate(layoutInflater)

    override fun isStatusBarTranslate(): Boolean = true
    override fun isShowToolBar(): Boolean = false

    override fun initViews() {
        super.initViews()
        StatusBarUtils.setStatusBarHeight(mViewContentBinding.statusView)
        StatusBarUtils.setStatusBarForegroundColor(this, true)

        val headTitleUtils = HeadTitleUtils(this)
        headTitleUtils.setTitle(getString(R.string.ac_circle_check_ac_details_title))
        headTitleUtils.setLineStyle(10)


        //上下拉刷新
        mViewContentBinding.pdView.setEnableLoadMore(false)
        mViewContentBinding.pdView.setEnableLoadMoreWhenContentNotFull(false)
        getRefreshFooter()?.let { mViewContentBinding.pdView.setRefreshFooter(it) }
        mViewContentBinding.pdView.setRefreshHeader(
            ClassicsHeader(this).setAccentColor(
                ContextCompat.getColor(this, R.color.color_999999)
            )
        )

    }

    override fun lazyInitData() {
        super.lazyInitData()
    }


    override fun initEvents() {
        super.initEvents()

        mViewContentBinding.pdView.setRefreshFooter(
            ClassicsFooter(this).setAccentColor(
                ContextCompat.getColor(this, R.color.color_999999)
            )
        )

        mViewContentBinding.pdView.setOnRefreshLoadMoreListener(object : OnRefreshLoadMoreListener {
            override fun onLoadMore(refreshLayout: RefreshLayout) {
            }

            override fun onRefresh(refreshLayout: RefreshLayout) {
                refreshLayout.layout.postDelayed({
                    finishPdView()
                }, 1000)
            }
        })

    }

    override fun onClick(v: View?) {
        when (v) {
        }
    }

    private fun finishPdView() {
        mViewContentBinding.pdView.finishRefresh()
        mViewContentBinding.pdView.finishLoadMore()
        mViewContentBinding.pdView.setNoMoreData(true)
    }
}